﻿@model MessageViewModel
<form class="layui-form" asp-controller="Plus" asp-action="MessageSend">
	<div class="layui-form-item">
		<label class="layui-form-label">收件人</label>
		<div class="layui-input-block">
			@{
				if (Model.MessageID <= 0)
				{
					<span class="select-box inline">
						<select id="dropInceptType" class="select" onchange="SelectInceptType()" asp-for="InceptType" lay-ignore>
							<option value="0">所有会员</option>
							<option value="1">指定会员</option>
							<option value="2">指定会员组</option>
						</select>
					</span>
					<span id="conIncept" style="display:none;">
						@await Component.InvokeAsync("SelectUser", new SelectUserViewModel { Prefix = "ctl", Value = ViewBag.Incept, IsRequired = true })
					</span>
					<span id="conInceptGroup" style="display:none;">
						<span class="select-box inline" style="min-width:200px;">
							<select asp-for="InceptGroup" data-val="true" data-val-required="不能为空" id="InceptGroup" class="select" style="padding:0px;width:100%;" lay-ignore></select>
						</span>
						<span style="color:red;" class="field-validation-valid" data-valmsg-for="InceptGroup" data-valmsg-replace="true"></span>
					</span>
				}
				else
				{
					<span class="select-box inline">
						<select id="dropInceptType" class="select" asp-for="InceptType" lay-ignore>
							<option value="1">指定会员</option>
						</select>
					</span>
					<span id="conIncept">
						@await Component.InvokeAsync("SelectUser", new SelectUserViewModel { Prefix = "ctl", Value = ViewBag.Incept, IsRequired = true })
					</span>
				}
			}
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">发件人</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" asp-for="Sender">
			<span asp-validation-for="Sender" style="color:red;"></span>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">标题</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" asp-for="Title">
			<span asp-validation-for="Title" style="color:red;"></span>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">内容</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" asp-for="Content"></textarea>
			<span asp-validation-for="Content" style="color:red;"></span>
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn layuiadmin-btn-list" type="submit">发送</button>
			<button class="layui-btn layuiadmin-btn-list" type="button" onclick="layer_close()">取消</button>
			<input type="hidden" asp-for="MessageID" />
			<span style="color:red; font-size:18px;">@Html.ValidationSummary(true)</span>
		</div>
	</div>
</form>
@section scripts{
	<script type="text/javascript">
		function SelectInceptType() {
			var InceptType = $("#dropInceptType").val();
			if (InceptType == "0") {
				$("#conIncept").hide();
				$("#conInceptGroup").hide();
				$("#ctlSelectUser").attr("disabled", true);
				$("#InceptGroup").attr("disabled", true);
			}
			else if (InceptType == "1") {
				$("#conIncept").show();
				$("#conInceptGroup").hide();
				$("#ctlSelectUser").attr("disabled", false);
				$("#InceptGroup").attr("disabled", true);
			}
			else if (InceptType == "2") {
				$("#conIncept").hide();
				$("#conInceptGroup").show();
				$("#ctlSelectUser").attr("disabled", true);
				$("#InceptGroup").attr("disabled", false);
			}
		}
		$(function () {
			var result = "@Model.result";
			if (result == "ok") {
				RefreshParent();
			}
			else
			{
				loadUserGroupsAjax("InceptGroup", "@Model.InceptGroup", true);
				SelectInceptType();
			}
		});
	</script>
}
